﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Resources/BrushResources.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ScrollBar_PageRepeatButtonStyle" TargetType="RepeatButton">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <Border Background="Transparent" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBar_LineRepeatButtonStyle" TargetType="RepeatButton">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <Border 
                        Name="Border"
                        CornerRadius="6" 
                        BorderThickness="1"
                        >
                        <Path 
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Fill="#6D99BA"
                            Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" 
                            />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="Green" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="Pink"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScollBar_ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border 
                        CornerRadius="2" 
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="1"
                        />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ScrollBar">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollBar">
                    <Border DockPanel.Dock="Right">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition MaxHeight="25"/>
                                <RowDefinition Height="0.00001*"/>
                                <RowDefinition MaxHeight="25"/>
                            </Grid.RowDefinitions>

                            <Border
                                Grid.RowSpan="3"
                                CornerRadius="5" 
                                BorderBrush="#6D99BA"
                                BorderThickness="1"
                                Background="#EDF5FB" 
                                />

                            <RepeatButton
                                Grid.Row="0"
                                Command="ScrollBar.LineUpCommand"
                                Style="{StaticResource ScrollBar_LineRepeatButtonStyle}"
                                Content="M 0 4 L 8 4 L 4 0 Z" 
                                />

                            <RepeatButton
                                Grid.Row="2"
                                Command="ScrollBar.LineDownCommand"
                                Style="{StaticResource ScrollBar_LineRepeatButtonStyle}"
                                />

                            <Track                                 x:Name="PART_Track"                                Grid.Row="1"                                IsDirectionReversed="True"                                >
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton
                                        Command="ScrollBar.PageUpCommand"
                                        Style="{StaticResource ScrollBar_PageRepeatButtonStyle}"
                                        />
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb
                                        Style="{StaticResource ScollBar_ScrollBarThumb}"
                                        Background="Yellow"
                                        BorderBrush="Black"
                                        Margin="1,0,1,0"
                                        />
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton
                                        Command="ScrollBar.PageDownCommand"
                                        Style="{StaticResource ScrollBar_PageRepeatButtonStyle}"
                                        />
                                </Track.IncreaseRepeatButton>
                            </Track>                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="Scroll_ScrollViewerStyle" TargetType="ScrollViewer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <DockPanel>
                        <ScrollBar
                            x:Name="PART_VerticalScrollBar"                            DockPanel.Dock="Right"                            Width="25"                            Value="{TemplateBinding VerticalOffset}"
                            Maximum="{TemplateBinding ScrollableHeight}"
                            ViewportSize="{TemplateBinding ViewportHeight}"
                            Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"                            />
                        <ScrollContentPresenter x:Name="_scrollContentPresenter" />
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>